<!-- 此页仅做动画效果展示， -->
<template>
	<scroll-view class="scroller blankPages" :scroll-into-view="toView" scroll-y="true" scroll-with-animation="true">		
		<u-transition :show="true" mode="slide-up" class="search_bg" id="tracingPoint0" v-if="tracingPointIndex>0">
			<view class="imgbg">
				<swiper class="swiper" circular :autoplay="true" :interval="150000" :duration="500" indicator-dots
					indicator-color="rgba(255,255,255,.3)" indicator-active-color="#ffffff">
					<swiper-item v-for="(item, index) in banner" :key="index" @click.stop="goBannerDetail(item)">
						<view class="swiper-item">
							<image :src="item.imgUrl" mode=""></image>
						</view>
					</swiper-item>
				</swiper>
			</view>
			<view class="flex align-center search_position">
				<view class="occupation" style="color: white;margin-left: -20rpx;margin-right: 12rpx;">
					{{labelPostName}}
				</view>
				<view class="search_box">
					<view class="left">
						<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/search.png" class="search"></image>
						<input type="text" placeholder="请输入搜索内容" placeholder-class="search_placeholder"
							v-model="searchValue" />
					</view>
					<view class="right">搜索</view>
				</view>
				<view class="message">
					<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/searchIfo.png"></image>
				</view>
			</view>
		</u-transition>
		<!-- 主体内容盒子----展现动态计算过程 -->
		<view class="animation-content animation-content_v2" v-if="tracingPointIndex>1">
			<view class="left-bg-line" mode="slide-left"></view>
			<view class="content-boxs" v-for="(series,index) in yzHomeData" :key="index">
				<!-- 动态的第二部分 -->
				<u-transition :show="true" mode="slide-up">
					<view id="tracingPoint1" class="content-items" style="margin-top: 20rpx;" v-if="tracingPointIndex>2&&series.type!=1">
						<view class="head">
							<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/blank-line-icon.png" mode=""></image>
							<view class="advancedTest">
								<image class="advancedTest-image" src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/advancedTest-icon.png" mode=""></image>
								<text> 进阶测验 </text>
							</view>
						</view>
					</view>
				</u-transition>
				<view class="content-items" id="tracingPoint1" >
					<u-transition :show="true" mode="slide-up">
						<view class="head">
							<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/blank-line-icon.png" mode=""></image>
							<h3 class="title">
								{{ series.name }}
							</h3>
							<u-line-progress class="itt-line-progress" activeColor="#FF9F5F" :percentage="30" :height="20">
								<text class="u-percentage-slot">.</text>
							</u-line-progress>
							<text class="u-percentage-numer"> 10% </text>
						</view>
					</u-transition>
					<u-transition :show="true" mode="slide-up">
						<view class="content-item-content_v2" style="transform: translateX(-20rpx);">
							<courseSeriesCardV2 v-for="(item,idn) in series.courseListVos" :key="idn" :item="item" @goDetail="toCourseInfo(item)" />
						</view>
					</u-transition>
				</view>
			</view>
		</view>
		<view id="tracingPoint5"></view>
		
		
		
		
		<!-- 以下弃用 -->
		<!-- 主体内容盒子----展现动态计算过程 -->
		<view class="animation-content" id="tracingPoint1" v-if="tracingPointIndex>1&&false">
			<u-transition class="left-bg-line" :show="true" mode="slide-left"></u-transition>
			<view class="content-boxs">yzHomeData
				<view class="content-items" >
					<u-transition :show="true" mode="slide-up">
						<view class="head">
							<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/blank-line-icon.png" mode=""></image>
							<h3 class="title">
								基础提示
							</h3>
							<u-line-progress class="itt-line-progress" activeColor="#FF9F5F" :percentage="30" :height="20">
								<text class="u-percentage-slot">.</text>
							</u-line-progress>
							<text class="u-percentage-numer"> 10% </text>
						</view>
					</u-transition>
					<u-transition :show="true" mode="slide-up">
						<view class="content-item-content">
							<view class="content-item-card">
								<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/card-head.png" mode=""></image>
								<view class=""card-content>
									<h4 class="title"> 产品文档基础 </h4>
									<view class="text">
										系列的简介文字占位，系列的简系列的简介文字占位...
									</view>
									<view class="cont-card-bottom">
										<text> 教师：王一 </text>
										<view class="already-study">
											已学：<text> 1% </text>
										</view>
									</view>
								</view>
							</view>
							<view class="content-item-card">
								<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/card-head.png" mode=""></image>
								<view class=""card-content>
									<h4 class="title"> 产品文档基础 </h4>
									<view class="text">
										系列的简介文字占位，系列的简系列的简介文字占位...
									</view>
									<view class="cont-card-bottom">
										<text> 教师：王一 </text>
										<view class="already-study">
											已学：<text> 1% </text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</u-transition>
				</view>
				<!-- 动态的第二部分 -->
				<u-transition :show="true" mode="slide-up">
					<view id="tracingPoint2" class="content-items" v-if="tracingPointIndex>2">
						<view class="head">
							<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/blank-line-icon.png" mode=""></image>
							<view class="advancedTest">
								<image class="advancedTest-image" src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/advancedTest-icon.png" mode=""></image>
								<text> 进阶测验 </text>
							</view>
						</view>
					</view>
				</u-transition>
				<view class="content-items" id="tracingPoint3" v-if="tracingPointIndex>3">
					<u-transition :show="true" mode="slide-up">
						<view class="head">
							<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/blank-line-icon.png" mode=""></image>
							<h3 class="title">
								进阶技能
							</h3>
							<u-line-progress class="itt-line-progress" activeColor="#FF9F5F" :percentage="30" :height="20">
								<text class="u-percentage-slot">.</text>
							</u-line-progress>
							<text class="u-percentage-numer"> 10% </text>
						</view>
					</u-transition>
					<u-transition :show="true" mode="slide-up">
						<view class="content-item-content">
							<view class="content-item-card">
								<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/card-head.png" mode=""></image>
								<view class=""card-content>
									<h4 class="title"> 产品文档基础 </h4>
									<view class="text">
										系列的简介文字占位，系列的简系列的简介文字占位...
									</view>
									<view class="cont-card-bottom">
										<text> 教师：王一 </text>
										<view class="already-study">
											已学：<text> 1% </text>
										</view>
									</view>
								</view>
							</view>
							<view class="content-item-card" >
								<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/card-head.png" mode=""></image>
								<view class=""card-content>
									<h4 class="title"> 产品文档基础 </h4>
									<view class="text">
										系列的简介文字占位，系列的简系列的简介文字占位...
									</view>
									<view class="cont-card-bottom">
										<text> 教师：王一 </text>
										<view class="already-study">
											已学：<text> 1% </text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</u-transition>
				</view>
				<!-- 动态的第三部分 -->
				<u-transition :show="true" mode="slide-up">
					<view id="tracingPoint4" class="content-items" v-if="tracingPointIndex>4">
						<view class="head">
							<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/blank-line-icon.png" mode=""></image>
							<view class="advancedTest">
								<image class="advancedTest-image" src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/advancedTest-icon.png" mode=""></image>
								<text> 进阶测验 </text>
							</view>
						</view>
					</view>
				</u-transition>
				<view class="content-items" id="tracingPoint5" v-if="tracingPointIndex>5">
					<u-transition :show="true" mode="slide-up">
						<view class="head">
							<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/blank-line-icon.png" mode=""></image>
							<h3 class="title">
								进阶技能
							</h3>
							<u-line-progress class="itt-line-progress" activeColor="#FF9F5F" :percentage="30" :height="20">
								<text class="u-percentage-slot">.</text>
							</u-line-progress>
							<text class="u-percentage-numer"> 10% </text>
						</view>
					</u-transition>
					<u-transition :show="true" mode="slide-up">
						<view class="content-item-content">
							<view class="content-item-card">
								<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/card-head.png" mode=""></image>
								<view class=""card-content>
									<h4 class="title"> 产品文档基础 </h4>
									<view class="text">
										系列的简介文字占位，系列的简系列的简介文字占位...
									</view>
									<view class="cont-card-bottom">
										<text> 教师：王一 </text>
										<view class="already-study">
											已学：<text> 1% </text>
										</view>
									</view>
								</view>
							</view>
							<view class="content-item-card" id="tracingPoint5" v-if="tracingPointIndex>5">
								<image src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/card-head.png" mode=""></image>
								<view class=""card-content>
									<h4 class="title"> 产品文档基础 </h4>
									<view class="text">
										系列的简介文字占位，系列的简系列的简介文字占位...
									</view>
									<view class="cont-card-bottom">
										<text> 教师：王一 </text>
										<view class="already-study">
											已学：<text> 1% </text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</u-transition>
				</view>
			</view>
		</view>
		<!-- 该空白页面的遮罩层及Loading -->
		<view class="blank-pages-mask" v-if="maskFlag">
			<view class="loading">
				<image  class="loadingIconCss"ref="loadingIcon" src="https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/occupation/loading-icon.gif" mode=""></image>
				<view> {{ loadingText }} </view>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	import { getBanner, getYzHome, memberLabel } from '@/apis/apis.js';
	import courseSeriesCardV2 from '@/pages/wx_subpack/courseSeriesCardV2.vue'
	export default {
		components: {
			courseSeriesCardV2,
		},
		data() {
			return {
				banner: [],
				searchValue: '',
				toView: '',
				tracingPointIndex: 0,
				loadingText: '正在计算...',
				maskFlag: false,
				yzHomeData: [],
				labelPostName: '职业体系',
			}
		},
		onLoad() {
			this.init()
		},
		// 文档准备完成生命周期，相当于Vue组件的mouted，此时才能拿到元素实例
		onReady(){
			this.calculationPageShowTimer()
			this.maskFlag = true
		},
		methods: {
			async init(){
				// 轮播
				const banner = await getBanner()
				this.banner = banner.data.reverse();
				let yzHome = await getYzHome()
				this.yzHomeData = yzHome.data || []
				let memberLabelData = (await memberLabel()).data
				console.log('已知首页数据：',yzHome,memberLabelData)
				this.labelPostName = memberLabelData.labelPostName
			},
			// 滚动到指定距离
			pageScrollTo(scrollTop=100, durationTime=300){
				setTimeout(()=>{
					uni.pageScrollTo({
						scrollTop: scrollTop,
						duration: durationTime
					});
				},10)
			},
			// 滚动到指定元素的位置 eId 元素的id属性(不含#)
			pageScrollToElement(eId="tracingPoint0"){
				const query = uni.createSelectorQuery().in(this);
				query.select(`#${eId}`).boundingClientRect(rect => {
					const rectTop = rect&&rect.top || 0
					console.log(rect,rectTop)
					this.pageScrollTo(rectTop)
				}).exec();
			},
			pageScrollToElementAsync(eId){
				setTimeout(()=>{
					this.pageScrollToElement(eId)
				},100)
			},
			// 按时间计算展示页面 5s展示完 动画展示 1s 2s 3.5s  5s
			calculationPageShowTimer(gapTime=5000){
				const query = uni.createSelectorQuery().in(this);
				setTimeout(()=>{
					console.log(query.select('#tracingPoint0'))
					this.tracingPointIndex = 1
					this.pageScrollToElementAsync('tracingPoint1')
					// #ifdef H5
					this.$refs.loadingIcon.$el.style.transform = 'rotate(180deg)'
					// #endif
				},500)
				setTimeout(()=>{
					this.tracingPointIndex = 2
					this.pageScrollToElementAsync('tracingPoint2')
					// #ifdef H5
					this.$refs.loadingIcon.$el.style.transform = 'rotate(360deg)'
					// #endif
				},1500)
				setTimeout(()=>{
					this.tracingPointIndex = 4
					this.pageScrollToElementAsync('tracingPoint3')
					// #ifdef H5
					this.$refs.loadingIcon.$el.style.transform = 'rotate(540deg)'
					// #endif
				},3000)
				setTimeout(()=>{
					this.tracingPointIndex = 9
					this.pageScrollToElementAsync('tracingPoint5')
					this.loadingText = '计算完成！'
					setTimeout(()=>{
						this.maskFlag = false
						uni.switchTab({
							url: '/pages/index/index'
						})
					},1500)
					// #ifdef H5
					this.$refs.loadingIcon.$el.style.transform = 'rotate(720deg)'
					// #endif
				},4500)
			},
			
		}
	}
</script>

<style lang="scss" scoped>
.blank-pages-mask{
	width: 100%;
	height: 100vh;
	background-color: rgba(0, 0, 0, .2);
	position: fixed;
	top: 0;
	left: 0;
	z-index: 999;
	.loading{
		color: #FFFFFF;
		letter-spacing: 2rpx;
		position: absolute;
		top: 40%;
		left: 50%;
		transform: translateX(-50%) translateY(-50%);
		text-align: center;
		image{
			width: 80rpx;
			height: 80rpx;
			border-radius: 50%;
			transition: all .5s;
		}
	}
}
// #tracingPoint0,#tracingPoint1,
// #tracingPoint2,#tracingPoint3,
// #tracingPoint4,#tracingPoint5{
// 	transition: all 2s;
// }
.animation-content{
	position: relative;
	z-index: 99;
	border-radius: 32rpx 32rpx 0 0;
	margin-top: -32rpx;
	background-color: #FFFFFF;
	min-height: calc(100vh - 480rpx);
	padding: 20rpx 30rpx;
	box-sizing: border-box;
	display: flex;
	.left-bg-line{
		width: 4rpx;
		height: calc(100% - 40px);
		min-height: calc(100vh - 480rpx);
		background-color: rgba(188, 211, 237, 0.5);
		border-radius: 2rpx;
		position: absolute;
		top: 30rpx;
	}
}
.animation-content_v2{
	display: block;
}
.animation-content .content-items{
	margin-bottom: 30rpx;
	margin-right: -40rpx;
	.head{
		transform: translateX(-30rpx);
		margin-bottom: 0rpx;
		image{
			width: 61rpx;
			height: 61rpx;
			vertical-align: middle;
		}
		.title{
			padding-bottom: 6rpx;
			padding-right: 6rpx;
			display: inline-block;
			margin-right: 14rpx;
			background-image: url('https://yzxk.oss-cn-hangzhou.aliyuncs.com/images/interest/title-bg.png');
			background-size: contain;
			background-repeat: no-repeat;
			background-position: bottom;
			width: 166rpx;
			white-space: nowrap;
			text-overflow: ellipsis;
			-webkit-line-clamp: 1;
			overflow: hidden;
			transform: translateY(12rpx);
		}
		.itt-line-progress{
			width: 370rpx;
			display: inline-block;
			margin-right: 6rpx;
		}
		.u-percentage-numer{
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 500;
			color: #FF9F5F;
			line-height: 46rpx;
			width: 120rpx;
			text-align: right;
			display: inline-block;
		}
		.u-percentage-slot{
			display: inline-block;
			width: 10rpx;
			height: 10rpx;
			background-color: #FFFFFF;
			margin-right: 10rpx;
			border-radius: 50%;
		}
	}
	.content-item-content{
		width: 720rpx;
		padding-left: 30rpx;
		display: flex;
		overflow-x: auto;
	}
	.content-item-content_v2{
		width: 720rpx;
		padding-left: 30rpx;
	}
	.content-item-card{
		width: 434rpx;
		height: 467rpx;
		background: #FFFFFF;
		box-shadow: 0px 3rpx 26rpx 0px rgba(206,206,206,0.3);
		border-radius: 20rpx;
		margin-right: 25rpx;
		margin-bottom: 30rpx;
		image{
			width: 434rpx;
			height: 233rpx;
			background: #CDCDCD;
			border-radius: 20rpx 20rpx 0rpx 0rpx;
		}
		.title{
			height: 31rpx;
			font-size: 32rpx;
			font-family: Source Han Sans CN;
			font-weight: 600;
			color: #111111;
			line-height: 44rpx;
			margin: 20rpx;
		}
		.text{
			padding: 0 20rpx;
			font-size: 28rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #808080;
			line-height: 44rpx;
		}
		.cont-card-bottom{
			margin-top: 10rpx;
			display: flex;
			justify-content: space-between;
			line-height: 54rpx;
			padding: 0 20rpx;
			.already-study{
				width: 174rpx;
				height: 54rpx;
				background: #FFFFFF;
				opacity: 0.8;
				border-radius: 14rpx;
				padding: 2rpx 14rpx;
				font-size: 28rpx;
				font-weight: bold;
				text{
					color: #FF9F5F;
					font-weight: 500;
				}
				.textGreen{
					color: green;
				}
			}
		}
	}
}

.advancedTest{
	width: 190rpx;
	height: 60rpx;
	background: #369CFE;
	box-shadow: 0px 5rpx 10rpx 0px rgba(52,144,233,0.3), 0px -2px 7px 0px rgba(54,156,254,0.3);
	border-radius: 16rpx;
	display: inline-block;
	color: #FFFFFF;
	font-size: 28rpx;
	font-family: PingFang SC;
	font-weight: 500;
	line-height: 53rpx;
	text-align: center;
	transform: translateY(-10rpx);
	.advancedTest-image{
		width: 24rpx !important;
		height: 24rpx !important;
		vertical-align: middle;
		margin-right: 10rpx;
	}
}
	
	
	

.imgbg {
	width: 100%;
	height: 500rpx;
	position: relative;

	.swiper {
		width: 100%;
		height: 100%;

		.swiper-item {
			width: 100%;
			height: 100%;
			border-radius: 0 0 0rpx 0rpx;
			overflow: hidden;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}
}

.search_position {
	position: absolute;
	left: 43rpx;
	top: 84rpx;
}
.flex {
	display: flex;
}
.justify_between {
	justify-content: space-between;
}
.align-center {
	align-items: center;
}
.search_box {
	width: 586rpx;
	height: 70rpx;
	background: rgba(246,248,249,0.3);
	border-radius: 35rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
	overflow: hidden;
	color: #fff;
	.left {
		height: 100%;
		flex: 1;
		display: flex;
		align-items: center;

		.search {
			width: 36rpx;
			height: 36rpx;
			margin: 0 20rpx 0 30rpx;
		}

		&>input {
			height: 100%;
			flex: 1;
		}

		.search_placeholder {
			font-size: 28rpx;
			color: #FFFFFF;
		}

		.text {
			color: #fff;
			font-size: 30rpx;
			line-height: 52rpx;
		}
	}

	.right {
		height: 100%;
		display: flex;
		align-items: center;
		color: #fff;
		font-size: 30rpx;
		padding: 0 20rpx;
	}
}

.loadingIconCss{
	// animation: loadingframe infinite 3s;
	width: 100vw !important;
	height: 100vw !important;
}
@keyframes loadingframe {
	0%{
		transform: rotate(0);
	}
	40%{
		transform: rotate(180deg)
	}
	50%{
		transform: rotate(360deg)
	}
	70%{
		transform: rotate(540deg)
	}
	100%{
		transform: rotate(720deg)
	}
}
</style>
